package org.smi.bt;

/**
 * @Author: ism
 * @Platform: Mac
 * @Date: 上午1:23 2018/7/7
 */
public class Demo {

    public static void main(String[] args) {

        System.out.println(System.getenv("app.name"));
        double[] tree = {4, 3, 5, 8, 7, 9};
        BsTree root = new BsTree(6);
        for(double length : tree) {
            root.insert(root, length);
        }

        root.insert(root, 4.1);

        BsTree arr[] = new BsTree[100];
        arr[0] = root;
        int length = 1;
        while(length > 0) {
            BsTree temp = arr[length - 1];
            System.out.println(temp.data);
            if(temp.right != null) {
                arr[length - 1] = temp.right;
                length++;
            }
            if(temp.left != null) {
                arr[length - 1] = temp.left;
                length++;
            }
            length--;
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
